////////////////////////////////////////////////////////////////////////////////
//
//  FLEX USER GROUP HOKURIKU
//  Copyright 2009 Flex User Group Hokuriku
//  All Rights Reserved.
// 
//  NOTICE: Flex User Group Hokuriku permits you to use, 
//  modify, and distribute this file 
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package net.fxug.hokuriku.chocolat.dao
{
    import flash.events.SQLErrorEvent;
    import flash.events.SQLEvent;

    import mx.logging.Log;
    import mx.logging.targets.TraceTarget;

    import org.flexunit.Assert;
    import org.flexunit.async.Async;


    public class DatabaseManagerTest
    {
        // Reference declaration for class to test
        private var target:DatabaseManager = DatabaseManager.getInstance();

        public function DatabaseManagerTest()
        {
        }

        [Test(async, timeout="3000")]
        public function testConnect():void
        {
            Log.addTarget(new TraceTarget());
            this.target.addEventListener(SQLEvent.OPEN, Async.asyncHandler(this, function(e:SQLEvent, throwsData:Object):void
                {
                    Assert.assertTrue(true);
                }, 1500));
//            this.target.addEventListener(SQLErrorEvent.ERROR, Async.asyncHandler(this, function(event:SQLErrorEvent, passThrowsData:Object):void
//                {
//                    Assert.fail("error...");
//                }, 1500));
            this.target.connect();
        }
//
//        private function handler(event:SQLEvent, passThrowsData:Object):void
//        {
//            var dao:SessionDao = new SessionDao();
//            dao.atndId = 11;
//            dao.sessionTag = "$test";
//            dao.startDatetime = new Date();
//            dao.title = "#hogehoge";
//            this.target.addEventListener(SQLVoteEvent.INSERT_SESSION_EVENT, Async.asyncHandler(this, function(event:SQLVoteEvent, passThrowsData2:Object):void
//                {
//                    trace(event);
//
//                }, 300));
//            this.target.addEventListener(SQLErrorEvent.ERROR, Async.asyncHandler(this, function(e2:SQLErrorEvent, passThrowsData3:Object):void
//                {
//                    trace(e2);
//                }, 300));
//            this.target.insertSession(dao);
//        }
    }
}